<!DOCTYPE html>
<html lang="en">
<head>
    <title>Title</title>
    <#include "common.ftl" />
    <style>
        body {
            width: 100%!important;
            height: 100%!important;
            background: url(${ticket.contextPath}/static/web/img/bg-order-phone.jpg) no-repeat center fixed;
            background-size: 100% 100%;
        }
    </style>
    <script>
        <#--var account = ${account}-->
        $(function() {
            loginToken = $.cookie('loginToken');
            if(!loginToken){
                console.log("跳转")
                window.location.href = "/web/page/auth";
            }
            <#--console.log(${account})-->
            findOrders()
        });
        function findOrders(){
            var url="/web/api/orders";
            $.ajax({
                type:'GET',
                url:url,
                processData:false,
                contentType: false,
                cache: false,
                beforeSend: function(request) {
                    request.setRequestHeader("Authorization", "Bearer "+loginToken);
                },
                success:function(data){
                    if(data!=null){
                        $.each(data, function(index, order) {
                            // url = "/web/api/order?orderId="+order.id +"&account="+account+"&token="+loginToken;
                            url = "/web/api/auto/one?orderId="+order.id +"&token="+loginToken;
                            // qiangUrl="/web/api/order/qiang?orderId="+order.id +"&account="+account +"&token="+loginToken;
                            qiangUrl="/web/api/auto/direct?orderId="+order.id +"&token="+loginToken;
                            autoUrl="/web/api/auto/all?orderId="+order.id +"&token="+loginToken;
                            $("#orderList").append("<li class=\"userLi\">" +
                                    "<span style=\"display: block\">"+order.projectName+"</span>"+
                                    "<span  style=\"display: inline-block\">￥"+order.priceName+" * "+order.number+"</span>"+
                                    "<button style=\"display:inline-block;float: right\" onclick=\"del("+order.id+")\" >删除&nbsp;&nbsp;</button>"+
                                    "<a style=\"display:inline-block;float: right\" href=\""+url+"\" target=\"_blank\">半自动&nbsp;&nbsp;</a>"+
                                    "<a style=\"display:inline-block;float: right\" href=\""+qiangUrl+"\" target=\"_blank\">直接&nbsp;&nbsp;</a>"+
                                    "<a style=\"display:inline-block;float: right\" href=\""+autoUrl+"\" target=\"_blank\">自动&nbsp;&nbsp;</a>"+
                                    "</li>");
                        });
                    }
                },
                error:function(err){
                    var ss = JSON.stringify(err)
                    console.log(ss)
                }
            })
        }
        function del(orderId) {
            var url="/web/api/orders?orderId="+orderId;
            $.ajax({
                type:'DELETE',
                url:url,
                processData:false,
                contentType: false,
                cache: false,
                beforeSend: function(request) {
                    request.setRequestHeader("Authorization", "Bearer "+loginToken);
                },
                success:function(data){
                    if(data!=null ){
                        console.log("删除操作："+data)
                        window.location.reload()
                    }
                },
                error:function(err){
                    var ss = JSON.stringify(err)
                    alert("删除失败")
                }
            })
        }

    </script>
</head>
<body  id="homeBody">
<script>
    if(/Android|webOS|iPhone|iPad|BlackBerry/i.test(navigator.userAgent)) {
        console.log(document.getElementById("homeBody"))
        document.getElementById("homeBody").style.background="url(${ticket.contextPath}/static/web/img/bg-order-phone.jpg) no-repeat center fixed";
        document.getElementById("homeBody").style.backgroundSize="100% 100%";
    }
</script>
<div  class="container">
    <div class="row" style="margin-top: 10%;">
        <div class="col-xs-12" style="text-align: center;">
            <p style="color: #a69393;font-family: 楷体;font-size: 30px;font-weight:bold;">点击进行抢票</p>
        </div>
        <ul id="orderList" class="col-xs-offset-2 col-xs-8" style="list-style-type: decimal;">

        </ul>
    </div>
</div>
</body>
</html>